<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Words Module</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Words Module' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../services.html">Services</a></li><li><a href="index.html">words</a></li><li><a href="index.html#1">Chapter 1: Setting Up</a></li><li><b>Words Module</b></li></ul></div>
<p class="purpose">Setting up the use of this module.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>This section simply sets up the module in ways expected by <a href="../foundation/index.html" class="internal">foundation</a>,
and contains no code of interest. The following constant exists only in tools
which use this module:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">WORDS_MODULE</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>This module defines the following classes:
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">source_file_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">vocabulary_entry_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">nonterminal_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">production_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">production_list_CLASS</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">ptoken_CLASS</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">source_file</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS_ALLOCATED_IN_ARRAYS</span><span class="plain-syntax">(</span><span class="reserved-syntax">vocabulary_entry</span><span class="plain-syntax">, </span><span class="constant-syntax">100</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">nonterminal</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">production_list</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">production</span><span class="plain-syntax">)</span>
<span class="identifier-syntax">DECLARE_CLASS</span><span class="plain-syntax">(</span><span class="reserved-syntax">ptoken</span><span class="plain-syntax">)</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Like all modules, this one must define a <span class="extract"><span class="extract-syntax">start</span></span> and <span class="extract"><span class="extract-syntax">end</span></span> function:
</p>

<pre class="definitions code-font"><span class="definition-keyword">enum</span> <span class="constant-syntax">LEXER_TEXT_MREASON</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">LEXER_WORDS_MREASON</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">LEXICAL_OUTPUT_DA</span>
<span class="definition-keyword">enum</span> <span class="constant-syntax">VOCABULARY_DA</span>
</pre>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">WordsModule::start</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Memory::reason_name</span><span class="plain-syntax">(</span><span class="constant-syntax">LEXER_TEXT_MREASON</span><span class="plain-syntax">, </span><span class="string-syntax">"source text"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Memory::reason_name</span><span class="plain-syntax">(</span><span class="constant-syntax">LEXER_WORDS_MREASON</span><span class="plain-syntax">, </span><span class="string-syntax">"source text details"</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Writers::register_writer</span><span class="plain-syntax">(</span><span class="character-syntax">'A'</span><span class="plain-syntax">, &amp;</span><a href="2-wa.html#SP8" class="function-link"><span class="function-syntax">WordAssemblages::writer</span></a><span class="plain-syntax">); </span><span class="comment-syntax"> </span><span class="extract"><span class="extract-syntax">%A</span></span><span class="comment-syntax"> = write word assemblage</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Writers::register_writer_I</span><span class="plain-syntax">(</span><span class="character-syntax">'N'</span><span class="plain-syntax">, &amp;</span><a href="3-lxr.html#SP19" class="function-link"><span class="function-syntax">Lexer::writer</span></a><span class="plain-syntax">);         </span><span class="comment-syntax"> </span><span class="extract"><span class="extract-syntax">%N</span></span><span class="comment-syntax"> = write word with this number</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Writers::register_writer</span><span class="plain-syntax">(</span><span class="character-syntax">'V'</span><span class="plain-syntax">, &amp;</span><a href="2-vcb.html#SP7" class="function-link"><span class="function-syntax">Vocabulary::writer</span></a><span class="plain-syntax">);      </span><span class="comment-syntax"> </span><span class="extract"><span class="extract-syntax">%V</span></span><span class="comment-syntax"> = write vocabulary entry</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Writers::register_writer_W</span><span class="plain-syntax">(</span><span class="character-syntax">'W'</span><span class="plain-syntax">, &amp;</span><a href="3-wrd.html#SP21" class="function-link"><span class="function-syntax">Wordings::writer</span></a><span class="plain-syntax">);      </span><span class="comment-syntax"> </span><span class="extract"><span class="extract-syntax">%W</span></span><span class="comment-syntax"> = write wording</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Log::declare_aspect</span><span class="plain-syntax">(</span><span class="constant-syntax">LEXICAL_OUTPUT_DA</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"lexical output"</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Log::declare_aspect</span><span class="plain-syntax">(</span><span class="constant-syntax">VOCABULARY_DA</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"vocabulary"</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">Writers::register_logger</span><span class="plain-syntax">(</span><span class="character-syntax">'f'</span><span class="plain-syntax">, </span><a href="2-wa.html#SP12" class="function-link"><span class="function-syntax">WordAssemblages::log</span></a><span class="plain-syntax">); </span><span class="comment-syntax"> </span><span class="extract"><span class="extract-syntax">$f</span></span><span class="comment-syntax"> = log word assemblage</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Writers::register_logger</span><span class="plain-syntax">(</span><span class="character-syntax">'v'</span><span class="plain-syntax">, </span><a href="2-vcb.html#SP5" class="function-link"><span class="function-syntax">Vocabulary::log</span></a><span class="plain-syntax">);      </span><span class="comment-syntax"> </span><span class="extract"><span class="extract-syntax">$v</span></span><span class="comment-syntax"> = log vocabulary entry</span>

<span class="plain-syntax">    </span><a href="3-lxr.html#SP12" class="function-link"><span class="function-syntax">Lexer::start</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="2-vcb.html#SP2" class="function-link"><span class="function-syntax">Vocabulary::create_punctuation</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="4-lp.html#SP6" class="function-link"><span class="function-syntax">LoadPreform::create_punctuation</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><a href="4-nnt.html#SP1" class="function-link"><span class="function-syntax">Nonterminals::register</span></a><span class="plain-syntax">();</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">WordsModule::end</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="P-htitm.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresscurrentchapter">1</li><li class="progresscurrent">wm</li><li class="progresschapter"><a href="2-vcb.html">2</a></li><li class="progresschapter"><a href="3-lxr.html">3</a></li><li class="progresschapter"><a href="4-ap.html">4</a></li><li class="progressnext"><a href="2-vcb.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

